import { AsyncComponentLoader } from 'vue';
import { CustomizedSvgIcons } from './customized.ts';
import { FaSvgIcons } from './fa.ts';
import { IconFont5SvgIcons } from './iconfont5.ts';
import type { DictionaryOption } from '#/Dictionary.d.ts';
const SvgIcons: Record<string, AsyncComponentLoader<any>> = { ...CustomizedSvgIcons, ...FaSvgIcons, ...IconFont5SvgIcons };
const getAllSvgIconList = (): Array<DictionaryOption> => {
	const customizedIconList: Array<DictionaryOption> = getSvgIconList('customized');
	const faIconList: Array<DictionaryOption> = getSvgIconList('fa');
	const iconfont5IconList: Array<DictionaryOption> = getSvgIconList('iconfont5');
	return [
		{
			key      : 'customized',
			label    : '自定义SVG图标',
			type     : 'group',
			children : customizedIconList
		},
		{
			key      : 'fa',
			label    : 'fa图标',
			type     : 'group',
			children : faIconList
		},
		{
			key      : 'iconfont5',
			label    : 'iconfont5图标',
			type     : 'group',
			children : iconfont5IconList
		}
	] as Array<DictionaryOption>;
};
const getSvgIconList = (svgLibName: string): Array<DictionaryOption> => {
	let keys;
	switch (svgLibName) {
		case 'customized':
			keys = Object.keys(CustomizedSvgIcons);
			break;
		case 'fa':
			keys = Object.keys(FaSvgIcons);
			break;
		case 'iconfont5':
			keys = Object.keys(IconFont5SvgIcons);
			break;
	}
	const icons: Array<DictionaryOption> = [];
	keys?.forEach(item => {
		const splitPre = item.replace(`/src/components/customComponents/icon/svg/${svgLibName}/`, '');
		const name = splitPre.replace('.vue', '');
		icons.push({ key : svgLibName, label : name, value : name, disabled : false });
	});
	return icons;
};
export { CustomizedSvgIcons, FaSvgIcons, IconFont5SvgIcons, SvgIcons, getAllSvgIconList };